package 四数之和;

import java.util.*;
import java.util.stream.Collectors;

public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();

        int[] nums = new int[]{1,0,-1,0,-2,2};



        solution.fourSum(nums,0);
    }

    public List<List<Integer>> fourSum(int[] nums, int target) {

        if(nums.length < 4){
            return new ArrayList<>();
        }

        List<Integer> list = Arrays.stream(nums).boxed().collect(Collectors.toList());

        Collections.sort(list);

        List<List<Integer>> result = new ArrayList<>();

        int start = 0;

        int left = start + 1;

        int size = list.size();
        int right = list.get(size -1);

        while(right - left >= 4){
            int leftIndex1 = left + 1;
            int leftIndex2 = leftIndex1 + 1;

            if(nums[left] + nums[leftIndex1] + nums[leftIndex2] + nums[right] == target){
                result.add(Arrays.asList(left,leftIndex1,leftIndex2,right));
            }
            else if(nums[left] + nums[leftIndex1] + nums[leftIndex2] + nums[right] > target){

            }

        }

        return null;
    }

//  [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]

}
